package com.kfm.usermanagement.controller;

import com.github.pagehelper.PageInfo;
import com.kfm.usermanagement.model.User;
import com.kfm.usermanagement.service.UserService;
import com.kfm.usermanagement.service.UserService2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;

// @RestController  //
@Controller
public class UserController {

    // private UserService service = new UserService();
    @Autowired
    private UserService2 service;

    @RequestMapping("/listPage")
    public ModelAndView userList(Integer pageNum, Integer pageSize,
                                 HttpServletRequest request, HttpSession session) {
        ModelAndView mv = new ModelAndView("userList");
        // PageInfo<User> page = service.findAll(pageNum, pageSize);
        // mv.addObject("page", page);
        return mv;
    }

    @RequestMapping("/all")
    @ResponseBody
    public List<User> findAll() {
        return service.findAll();
    }
}
